--- 战策九·趁火打劫
local policy9 = fk.CreateSkill {
    name = "attack_infire",
    tags = { Skill.Compulsory },
    dynamic_name = function (self, player, lang)
      return player == Self and self.name or "unknownpolicy"
    end,
    dynamic_desc = function (self, player, lang)
      return player == Self and self.name or "unknownpolicy"
    end,
}

local HG = require "packages.new_heg_diy_my.util"

Fk:loadTranslationTable {
    ["@[attack_infire_mark]"] = "趁火打劫",
    ["attack_infire_ask"] = "战策-趁火打劫：你可以获得其区域内各一张牌",
}

local U = require "packages.utility.utility"

policy9:addEffect(fk.EnterDying, {
    anim_type = "control",
    can_trigger = function(self, event, target, player, data)
        local mark_name = "@[private]" .. policy9.name .. "_mark"
        return player:getMark(mark_name) ~= 0 and target ~= player and #target:getCardIds("heg") > 0
    end,
    on_cost = function(self, event, target, player, data)
        return player.room:askToSkillInvoke(player, { skill_name = "unknownpolicy", prompt = "attack_infire_ask" })
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local mark_name = "@[private]" .. policy9.name .. "_mark"
        local cards = U.askforCardsChosenFromAreas(player, target, "hej", policy9.name, nil, nil, false)
        room:moveCardTo(cards, Card.PlayerHand, player, fk.ReasonGive, policy9.name, nil, false, player)
        room:setPlayerMark(player, mark_name, 0)
        room:handleAddLoseSkills(player, "-attack_infire", nil, false)
        room.logic:trigger(HG.HegLosePolicy, player, { player, policy9.name })
        local card = Fk:cloneCard("heg_attack_infire")
        room:getVirtCardId(card)
        room:showVirtualCard(card, player, nil, room.logic:getCurrentEvent().id + 1)
    end,
})

return policy9
